package cn.tedu.boot07.controller;

import cn.tedu.boot07.entity.Product;
import cn.tedu.boot07.mapper.ProductMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 作者：HeShaoShuai
 * @Email 邮箱：2569819541@qq.com
 * @Date 日期：2023/5/12 16:30
 * @Package 包名：cn.tedu.boot07.controller
 * @Project 项目名：JavaSE
 * @Version 1.0
 */
@RestController
public class ProductController {
	@Autowired
	ProductMapper mapper;
	@RequestMapping("/insert")
	public void insert(@RequestBody Product product){
		System.out.println("product = " + product);
		mapper.insert(product);
	}
	@RequestMapping("/select")
	public List<Product> select(){
		return mapper.select();
	}
	@RequestMapping("/delete")
	public void delete(int id){
		mapper.deleteById(id);
	}
	@RequestMapping("/selectById")
	public Product selectById(int id){
		return mapper.selectById(id);
	}
	@RequestMapping("/update")
	public void update(@RequestBody Product product){
		mapper.update(product);
	}
}
